

package com.hazelcast.internal.nio.ascii;

import com.hazelcast.config.RestApiConfig;
import com.hazelcast.test.AssertTask;
import com.hazelcast.test.TestAwareInstanceFactory;
import org.junit.After;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Shared code for {@link RestApiConfig} and {@link TextProtocolFilter} testing.
 */
public abstract class AbstractTextProtocolsTestBase {

    protected final TestAwareInstanceFactory factory = new TestAwareInstanceFactory();

    @After
    public void cleanup() {
        factory.terminateAll();
    }

    protected AssertTask createResponseAssertTask(final String message, final TextProtocolClient client, final String expectedSubstring) {
        return () -> assertThat(client.getReceivedString()).as(message).contains(expectedSubstring);
    }
}
